﻿using System;
namespace Producers.Ehr.Xtee.Riik.Ee.Producer.Ehr {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="EN_OtsiDokumenti_query", Namespace="http://producers.ehr.xtee.riik.ee/producer/ehr", Target=typeof(ENOtsiDokumentiQuery))]
    public class ENOtsiDokumentiQuerySerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IENOtsiDokumentiQuery clazz;
        
        public ENOtsiDokumentiQuerySerializer(IENOtsiDokumentiQuery clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.EhrKood!=null) {
                Writer.WriteStartElement("ehr_kood");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.EhrKood))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
        START:
            if ((Reader.LocalName == "ehr_kood")) {
                goto ehr_kood;
            }
            else {
                return;
            }
        ehr_kood:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>EN_OtsiDokumenti_query>ehr_kood");
            }
            clazz.EhrKood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("ehr_kood")).Value;
            goto START;
        }
    }
}
